﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<TemplateWeb.Models.ViewModels.GroupViewModel>" %>
<script type="text/javascript">
    function submitForm2(soluongton, idsanpham) {
        if (parseInt(soluongton) <= 0) {
            alert("Không thể tạo phiên đấu giá khi số lượng tồn <= 0");
        } else {
            location.href = "../../Admin/CreatePhienDauGia?idsanpham=" + idsanpham;
        }
    }
</script>
<div class="AdminPageText">
List Of SanPham
</div>
<table class="Grid" cellpadding="0" cellspacing="0">
	<thead>
		<tr>
            <th>HinhAnh</th>
			<th>TenSanPham</th>
			<th>XuatXu</th>
			<th>SoLuongTon</th>
			<th></th>
			<th></th>
            <th></th>
		<tr>
	</thead>
	<% for (int i=0; i<Model.SanPhamModel.GetModel.LstObjModel.Count; i++){
		if (i % 2 != 0) {%>
		<tr class="Row" id="row-<%= Model.SanPhamModel.GetModel.LstObjModel[i].ID %>">
		<% }
		else { %>
		<tr class="AlternatingRow" id="row-<%= Model.SanPhamModel.GetModel.LstObjModel[i].ID %>">
		<% } %>
            <td><img src="../../../Content/Images/Items/<%= Model.SanPhamModel.GetModel.LstObjModel[i].HinhAnh %>" width="60px" height="60px" /></td>
			<td><span style=""><%= Model.SanPhamModel.GetModel.LstObjModel[i].TenSanPham %></span></td>
			<td><span style=""><%= Model.SanPhamModel.GetModel.LstObjModel[i].XuatXu %></span></td>
			<td><span style=""><%= Model.SanPhamModel.GetModel.LstObjModel[i].SoLuongTon %></span></td>
			<td>
				<a href="../../Admin/DetailOfSanPham?id=<%= Model.SanPhamModel.GetModel.LstObjModel[i].ID %>">
					<span style="color: Blue; text-decoration: underline">Select</span>
				</a>
			</td>
			<td>
                <%= Ajax.ActionLink("Delete", "DeleteSanPham", "Admin", new { id = Model.SanPhamModel.GetModel.LstObjModel[i].ID }, new AjaxOptions { Confirm = "Are you sure you want to Delete it? This action cannot be undone.", HttpMethod = "Delete", OnComplete = "jsonDelete_OnComplete" })%>
			</td>
            <td>
                <a href="#" onclick="submitForm2('<%= Model.SanPhamModel.GetModel.LstObjModel[i].SoLuongTon %>', '<%= Model.SanPhamModel.GetModel.LstObjModel[i].ID %>');">
					<span style="color: Blue; text-decoration: underline">Tạo phiên mới</span>
				</a>
			</td>
		</tr>
	<% } %>  
</table>
